<?php

return [
    'server' => [
        'swConfig' => [
            'pid_file'              => runtime_path() . 'mqtt-server.pid',
            'log_file'              => runtime_path() . 'mqtt-server.log',
            'open_mqtt_protocol'    => true,
            'daemonize'             => false,
            'reactor_num'           => swoole_cpu_num(),
            'worker_num'            => swoole_cpu_num(),
            'task_worker_num'       => swoole_cpu_num(),
            'enable_static_handler' => true
        ],
        // Swoole 接受信息后事件回调
        'event' => \iflow\swoole\implement\Server\Mqtt\Events\Event::class,
        // MQTT 信息回调
        'messageType' => '',
        'mqttEvent' => [
            'connectAfter' => '',
            'protocol_level' => 5, // 协议等级，MQTT3.1.1版本为4，5.0版本为5，MQIsdp为3
        ],
        'options' => [],
        'host' => [
            'host' => '127.0.0.1',
            'port' => 8092
        ]
    ],
    'client' => [
//        'host' => 'broker-cn.emqx.io', // MQTT服务端IP
//        'port' => 1883, // MQTT服务端端口
//        'userName' => 'admin', // 用户名
//        'passWord' => '123456', // 密码
        'host' => '127.0.0.1', // MQTT服务端IP
        'port' => 1883, // MQTT服务端端口
        'userName' => '', // 用户名
        'passWord' => '', // 密码
        'clientId' => \Simps\MQTT\Client::genClientID(), // 客户端id
        'keep_alive' => 20, // 默认0秒，设置成0代表禁用
        'ping_time' => 10, // 默认0秒，设置成0代表禁用
        'protocolName' => 'MQTT', // 协议名，默认为MQTT(3.1.1版本)，也可为MQIsdp(3.1版本)
        'protocolLevel' => 5, // 协议等级，MQTT3.1.1版本为4，5.0版本为5，MQIsdp为3
        'properties' => [], // MQTT5 中所需要的属性
        'delay' => 3, // 重连时的延迟时间
        'swConfig' => [
            'pid_file'              => runtime_path() . 'mqtt-client.pid',
            'log_file'              => runtime_path() . 'mqtt-client.log',
            'open_mqtt_protocol'    => true,
            'daemonize'             => false,
            'reactor_num'           => swoole_cpu_num(),
            'worker_num'            => swoole_cpu_num(),
            'task_worker_num'       => swoole_cpu_num(),
            'package_max_length'    => 2 * 1024 * 1024,
            'connect_timeout'       => 1.0,
            'write_timeout'         => 3.0,
            'read_timeout'          => 0.5,
//            'ssl_cert_file'         => '/usr/local/webserver/ssl/server.crt',
//            'ssl_key_file'          => '/usr/local/webserver/ssl/server.key',
        ], // swoole Config
        'sockType' => SWOOLE_TCP | SWOOLE_SSL,
        'clientType' => \Simps\MQTT\Client::COROUTINE_CLIENT_TYPE,
        // 接受信息回调
        'event' => '',
        // 连接后
        'connectBefore' => '',
        // 断开链接
        'closeConnection' => '',

        // 主题列表
        'topics' => [
            'test' => [
                'qos' => 0,
                'no_local' => true,
                'retain_as_published' => true,
                'retain_handling' => 2,
            ]
        ],

        // 连接配置
        'connect' => [
            'clean' => true,
            'will' => []
        ]
    ]
];
